package com.tucc.hello.leetcode.no1601_2000.no1800;

/**
 * @author tucc
 * @description todo
 * @package com.tucc.hello.leetcode
 * @date 2021/5/20
 **/
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] arr = {10,20,30,5,10,50};
        System.out.println(solution.maxAscendingSum(arr));
    }

    public int maxAscendingSum(int[] nums) {
        int pre = nums[0];
        int max = pre;
        int curSum = pre;
        for(int i = 1;i < nums.length;i ++){
            if(nums[i] > pre){
                curSum += nums[i] ;
            }
            else{
                curSum = nums[i];
            }
            pre = nums[i];
            max = Math.max(curSum, max);
        }
        return max;
    }
}
